﻿#ifndef LEGENDBASE_H
#define LEGENDBASE_H

#include <QGraphicsSimpleTextItem>
#include <QStringList>
class LegendBase : public QGraphicsSimpleTextItem
{
public:
    inline explicit LegendBase(QGraphicsItem *parent = nullptr)
        :QGraphicsSimpleTextItem(parent)
        ,mLegends()
        {}
    inline explicit LegendBase(const QString &legend, QGraphicsItem *parent = nullptr)
        :QGraphicsSimpleTextItem(legend,parent)
        ,mLegends(legend)
        {}
    inline explicit LegendBase(const QStringList& legends, QGraphicsItem *parent = nullptr)
        :QGraphicsSimpleTextItem(legends.join('\n'),parent)
        ,mLegends(legends)
        {}

    inline ~LegendBase(){}
    void append(const QString& legend);
    void append(const QStringList& legends);
    bool insert(unsigned int index,const QString& legend);
    bool insert(unsigned int index,const QStringList& legends);
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
signals:

public slots:

private:
    QStringList mLegends;// 标注列表，每个string站一行
};

#endif // LEGENDBASE_H
